package ma.xin.shi.arxml.comm;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class XmlHelper {

    /**
     * 创建带有文本内容的 XML 元素
     */
    public static Element createElementWithText(Document doc, String tagName, String textContent) {
        Element element = doc.createElement(tagName);
        if (textContent != null && !textContent.isEmpty()) {
            element.setTextContent(textContent);
        }
        return element;
    }

    /**
     * 创建空元素，如 <CATEGORY/>
     */
    public static Element createEmptyElement(Document doc, String tagName) {
        Element element = doc.createElement(tagName);
        return element;
    }
}
